package com.wuage.infrastructure.utils;

import com.wuage.infrastructure.exception.ResultCode;

/**
 * @author Shynin
 * @version 1.0
 * @date 9/27/21 10:09 AM
 */
public class ResponseBuild {
    private ResponseBuild(){
    }

    public static <T> Response<T> fail(String message) {
        return fail(-1, message);
    }

    public static <T> Response<T> fail(Integer code, String message) {
        Response<T> Response = new Response<>();
        Response.setMsg(message);
        Response.setCode(code);
        return Response;
    }

    public static <T> Response<T> fail(ResultCode resultCode) {
        return fail(resultCode.getCode(), resultCode.getDesc());
    }

    public static <T> Response<T> success(T data) {
        Response<T> Response = new Response<>();
        Response.setData(data);
        Response.setCode(0);
        return Response;
    }

    public static <T> Response<T> success() {
        return success(null);
    }
}
